public class Test3 {
    public boolean solve (String A, String B) {
        // write code here
        int len1 = A.length();
        int len2 = B.length();
        if (len1 != len2) {
            return false;
        }
        for (int i = 0; i < A.length(); i++) {
            if (A.substring(0,i+1).equals(B.substring(len2-1-i, len2)) && A.substring(i+1, len1).equals(B.substring(0,len2-1-i))) {
                return true;
            }
        }
        return false;
    }
}
